home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / spiele / publicdomain / elan / src / amiga / console.h < prev    next >
C/C++ Source or Header  |  1996-06-07  |  2KB  |  67 lines

  1.  
  2. /*** Amiga/ANSI console I/O ***/
  3.  
  4. #include <stdio.h>
  5. #include <stdarg.h>
  6.  
  7. /* ANSI control sequences */
  8. #define ESC                     "\x1b"
  9. #define CSI                     ESC "["
  10. #define HOME                    CSI "H"
  11. #define ERASE2EOS               CSI "J"
  12. #define ERASE2EOL               CSI "K"
  13. #define CLS                     HOME ERASE2EOS
  14. #define LOCATE(i, j)            CSI i ";" j "H"
  15. #define SET_COLORS(fg, bg)      CSI "0;3" fg ";4" bg "m"
  16.  
  17. /* Amiga control sequences */
  18. #define SHOW_CURSOR             CSI " p"
  19. #define HIDE_CURSOR             CSI "0 p"
  20.  
  21. #define ANSI_COLORS_NUMBER      8
  22. #define ANSI_PAIRS_NUMBER       (ANSI_COLORS_NUMBER * ANSI_COLORS_NUMBER)
  23. #define REVERSE_BASE            ANSI_PAIRS_NUMBER
  24. #define PEN_NUMBER              (2 * REVERSE_BASE)
  25.  
  26. #define STRING_MAX_LEN          4096    /* Usato in con_printf */
  27.  
  28. typedef struct colors_pair
  29.     {
  30.     int fg;
  31.     int bg;
  32.     } colors_pair;
  33.  
  34. /* Dummy functions */
  35. #define locate(i, j)            (con_printf(LOCATE("%d", "%d"), (i) + 1, (j) + 1))
  36. #define clear_screen()          write_string(CLS)
  37. #define clear_to_eos()          write_string(ERASE2EOS)
  38. #define clear_to_eol()          write_string(ERASE2EOL)
  39. #define show_cursor()           write_string(SHOW_CURSOR)
  40. #define hide_cursor()           write_string(HIDE_CURSOR)
  41. #define reverse_pen(pen)        (REVERSE_BASE + (pen))
  42. #define begin_redraw()
  43. #define end_redraw()
  44.  
  45. /* Protos */
  46. int open_console(const char *title_string, int x, int y, int l, int h);
  47. void close_console(void);
  48. void write_char(char output_char);
  49. char read_char(void);
  50. char async_read_char(void);
  51. void write_string(const char *string);
  52. void con_printf(const char *format_string, ...);
  53. int register_pen(colors_pair pair);
  54. void set_pen(int pen);
  55.  
  56. /* Dummy protos
  57. void locate(int i, int j);
  58. void clear_screen(void);
  59. void clear_2_eos(void);
  60. void show_cursor(void);
  61. void hide_cursor(void);
  62. int reverse_pen(int pen);
  63. void begin_redraw(void);
  64. void end_redraw(void);
  65. */
  66.  
  67.